package com.jk.controller;

import com.jk.pojo.PostBean;
import com.jk.pojo.UserBean;
import com.jk.service.MyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

/**
 * 2 * @author lujintao
 * 3 * @description 类描述
 * 4 * @date 2021/11/16
 * 5 * @version </pre>
 * 6
 */
@Controller
@RequestMapping("my")
public class UserController {
    @Autowired
    private MyService myService;

    @RequestMapping("text")
    @ResponseBody
    public String text(){
        return myService.text();
    }
    @RequestMapping("zu")
    public String zu(){
        return "index";
    }
    @RequestMapping("index")
    public String index(){
        return "UserShow";
    }
    /*1 *
    2 * 登录
    3 * @author lujintao
    4 * @date 2021/11/16
    5 [q]
    6 * @return java.util.Map<java.lang.String,java.lang.String>
    7 */
    @RequestMapping("loginUser")
    @ResponseBody
    public Map<String,String> loginUser(UserBean q){
        return myService.loginUser(q);
    }
    /*1 *
    2 * 存session
    3 * @author lujintao
    4 * @date 2021/11/16
    5 [name, session]
    6 * @return void
    7 */
    @RequestMapping("SessUser")
    @ResponseBody
    public void SessUser(String name, HttpSession session){
        UserBean q=myService.SessUser(name);
        session.setAttribute("user",q);
    }
    @RequestMapping("toAddUser")
    public String toAddUser(){
        return "toAddUser";
    }
    /*1 *
    2 * 注册
    3 * @author lujintao
    4 * @date 2021/11/16
    5 [w]
    6 * @return void
    7 */
    @RequestMapping("addUser")
    @ResponseBody
    public void addUser(UserBean w){
        myService.addUser(w);
    }
    /*1 *
    2 * 用户管理
    3 * @author lujintao
    4 * @date 2021/11/16
    5 []
    6 * @return java.lang.String
    7 */
    @RequestMapping("UserShows")
    public String UserShows(){
        return "UserShows";
    }
    /*1 *
    2 * 查询用户
    3 * @author lujintao
    4 * @date 2021/11/16
    5 []
    6 * @return java.util.List<com.jk.pojo.UserBean>
    7 */
    @RequestMapping("selectAdmin")
    @ResponseBody
    public List<UserBean> selectAdmin(){
        return myService.selectAdmin();
    }
    @RequestMapping("ProtShow")
    public String ProtShow(){
        return "ProtShow";
    }
    /*1 *
    2 * 查询端口
    3 * @author lujintao
    4 * @date 2021/11/16
    5 []
    6 * @return java.util.List<com.jk.pojo.UserBean>
    7 */
    @RequestMapping("selectPort")
    @ResponseBody
    public List<PostBean> selectPort(){
        return myService.selectPort();
    }
    @RequestMapping("toAddPost")
    public String toAddPost(){
        return "toAddPost";
    }
    @RequestMapping("addPost")
    @ResponseBody
    public void addPost(PostBean e){
        myService.addPost(e);
    }
}
